/*
 *  Copyright 2005 Blandware (http://www.blandware.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.blandware.atleap.model.core.statistics;

import com.blandware.atleap.model.core.BaseObject;

/**
 * <p>Represents a unique user.</p>
 * <p><a href="Visitor.java.html"><i>View source</i></a></p>
 *
 * @author Roman Puchkovskiy <a href="mailto:roman.puchkovskiy@blandware.com">
 *         &lt;roman.puchkovskiy@blandware.com&gt;</a>
 * @version $Revision: 1.2 $ $Date: 2006/07/08 14:06:22 $
 */
public class Visitor extends BaseObject {

    /**
     * Visitor number
     */
    protected Integer number;

    /**
     * Browser ID
     */
    protected Integer browserId;

    /**
     * OS ID
     */
    protected Integer osId;

    /**
     * IP address
     */
    protected String ip;

    /**
     * Screen width
     */
    protected Integer screenWidth;

    /**
     * Screen height
     */
    protected Integer screenHeight;

    /**
     * User agent
     */
    protected UserAgent userAgent;

    /**
     * Number of sessions
     */
    protected Integer numberOfSessions;

    /**
     * Number of visits
     */
    protected Integer numberOfVisits;

    /**
     * Returns number.
     *
     * @return number
     */
    public Integer getNumber() {
        return number;
    }

    /**
     * Sets number.
     *
     * @param number number to set
     */
    public void setNumber(Integer number) {
        this.number = number;
    }

    /**
     * Returns browser ID.
     *
     * @return browser ID
     */
    public Integer getBrowserId() {
        return browserId;
    }

    /**
     * Sets browser ID.
     *
     * @param browserId ID to set
     */
    public void setBrowserId(Integer browserId) {
        this.browserId = browserId;
    }

    /**
     * Returns OS ID.
     *
     * @return OS ID
     */
    public Integer getOsId() {
        return osId;
    }

    /**
     * Sets OS ID.
     *
     * @param osId ID to set
     */
    public void setOsId(Integer osId) {
        this.osId = osId;
    }

    /**
     * Returns IP address.
     *
     * @return IP
     */
    public String getIp() {
        return ip;
    }

    /**
     * Sets IP address.
     *
     * @param ip IP to set
     */
    public void setIp(String ip) {
        this.ip = ip;
    }

    /**
     * Returns screen width.
     *
     * @return screen width
     */
    public Integer getScreenWidth() {
        return screenWidth;
    }

    /**
     * Sets screen width.
     *
     * @param screenWidth width to set
     */
    public void setScreenWidth(Integer screenWidth) {
        this.screenWidth = screenWidth;
    }

    /**
     * Returns screen height.
     *
     * @return screen height
     */
    public Integer getScreenHeight() {
        return screenHeight;
    }

    /**
     * Sets screen height.
     *
     * @param screenHeight height to set
     */
    public void setScreenHeight(Integer screenHeight) {
        this.screenHeight = screenHeight;
    }

    /**
     * Returns user agent.
     *
     * @return user agent
     */
    public UserAgent getUserAgent() {
        return userAgent;
    }

    /**
     * Sets user agent.
     *
     * @param userAgent user agent to set
     */
    public void setUserAgent(UserAgent userAgent) {
        this.userAgent = userAgent;
    }

    /**
     * Returns number of visitor sessions.
     *
     * @return number of sessions
     */
    public Integer getNumberOfSessions() {
        return numberOfSessions;
    }

    /**
     * Sets number of visitor sessions.
     *
     * @param numberOfSessions number to set
     */
    public void setNumberOfSessions(Integer numberOfSessions) {
        this.numberOfSessions = numberOfSessions;
    }

    /**
     * Returns number of visitor visits.
     *
     * @return number of visits
     */
    public Integer getNumberOfVisits() {
        return numberOfVisits;
    }

    /**
     * Sets number of visitor visits.
     *
     * @param numberOfVisits number to set
     */
    public void setNumberOfVisits(Integer numberOfVisits) {
        this.numberOfVisits = numberOfVisits;
    }

    /**
     * Returns screen resolution.
     *
     * @return screen resolution
     */
    public String getScreenResolution() {
        String result = "";
        if (screenWidth != null && screenHeight != null) {
            result = screenWidth.toString() + 'x' + screenHeight;
        }
        return result;
    }

    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Visitor)) {
            return false;
        }

        final Visitor visitor = (Visitor) o;

        if (number != null ? !number.equals(visitor.number) : visitor.number
                != null) {
            return false;
        }

        return true;
    }

    public int hashCode() {
        return (number != null ? number.hashCode() : 0);
    }
}
